package com.ruoyi.labdata.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labdata.domain.LabBlacklist;
import com.ruoyi.labdata.service.ILabBlacklistService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实验室黑名单基本信息Controller
 * 
 * @author ruoyi
 * @date 2022-04-02
 */
@RestController
@RequestMapping("/labdata/blacklist")
public class LabBlacklistController extends BaseController {
	@Autowired
	private ILabBlacklistService labBlacklistService;

	/**
	 * 查询实验室黑名单基本信息列表
	 */
	@PreAuthorize("@ss.hasPermi('labdata:blacklist:query')")
	@GetMapping("/list")
	public TableDataInfo list(LabBlacklist labBlacklist) {
		startPage();
		List<LabBlacklist> list = labBlacklistService.selectLabBlacklistList(labBlacklist);
		return getDataTable(list);
	}
	
	@GetMapping("/userlist")
	public TableDataInfo userlist(LabBlacklist labBlacklist) {
		startPage();
		List<LabBlacklist> list = labBlacklistService.queryLabBlackUserList(labBlacklist);
		return getDataTable(list);
	}

	/**
	 * 导出实验室黑名单基本信息列表
	 */
	// @PreAuthorize("@ss.hasPermi('labdata:blacklist:export')")
	/*@Log(title = "实验室黑名单基本信息", businessType = BusinessType.EXPORT)
	@GetMapping("/export")
	public AjaxResult export(LabBlacklist labBlacklist) {
		List<LabBlacklist> list = labBlacklistService.selectLabBlacklistList(labBlacklist);
		ExcelUtil<LabBlacklist> util = new ExcelUtil<LabBlacklist>(LabBlacklist.class);
		return util.exportExcel(list, "blacklist");
	}
*/
	/**
	 * 获取实验室黑名单基本信息详细信息
	 */
	@PreAuthorize("@ss.hasPermi('labdata:blacklist:query')")
	@GetMapping(value = "/{reservationId}")
	public AjaxResult getInfo(@PathVariable("reservationId") Long reservationId) {
		return AjaxResult.success(labBlacklistService.selectLabBlacklistByReservationId(reservationId));
	}
	@PreAuthorize("@ss.hasPermi('labdata:blacklist:query')")
	@GetMapping(value = "/getBlackUserInfo/{userBlackId}")
	public AjaxResult getLabBlackUserById(@PathVariable("userBlackId") Long userBlackId) {
		return AjaxResult.success(labBlacklistService.getLabBlackUserById(userBlackId));
	}
	//

	/**
	 * 新增实验室黑名单基本信息
	 */
	@PreAuthorize("@ss.hasPermi('labdata:blacklist:edit')")
	@Log(title = "实验室黑名单基本信息", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody LabBlacklist labBlacklist) {
		return toAjax(labBlacklistService.insertLabBlacklist(labBlacklist));
	}

	/**
	 * 修改实验室黑名单基本信息
	 */
	@PreAuthorize("@ss.hasPermi('labdata:blacklist:edit')")
	@Log(title = "实验室黑名单基本信息", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody LabBlacklist labBlacklist) {
		return toAjax(labBlacklistService.updateLabBlacklist(labBlacklist));
	}

	/**
	 * 删除实验室黑名单基本信息
	 */
	@PreAuthorize("@ss.hasPermi('labdata:blacklist:edit')")
	@Log(title = "实验室黑名单基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{blacklistIds}")
	public AjaxResult remove(@PathVariable Long[] blacklistIds) {
		return toAjax(labBlacklistService.deleteLabBlacklistByIds(blacklistIds));
	}
}
